using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_comments_latestcommentsl : Controls.DataManagerArchiveControl
{
    private int CurrentPage
    {
        get
        {
            int page;
            if (Helpers.QueryStringHelper.TryGetInt32("page", out page))
            {
                return page;
            }
            else
            {
                return 1;
            }
        }
    }

    protected override void ItemChanged()
    {
        if (CurrentArchive != null)
        {
            mviewLatestComments.SetActiveView(viewComments);
            lblHeader.Text = String.Format("<u>{0}</u><br />Latest Comments!", CurrentArchive.Title);
            Page.Title = String.Format("{0} - Latest Comments", CurrentArchive.Title);

            DAL.DataManagerPage<DAL.Quote> myDatasource = DAL.Quotes.GetLatestQuotesByArchiveAndPage(CurrentArchive, CurrentPage);
            Pager1.TotalPages = myDatasource.Pages;
            Pager1.UrlFormat = "~/fundies/latestcomments.aspx?archive=" + CurrentArchive.ID + "&page={0}";
            Pager1.CurrentPage = CurrentPage;
            Pager2.TotalPages = Pager1.TotalPages;
            Pager2.UrlFormat = Pager1.UrlFormat;
            Pager2.CurrentPage = Pager1.CurrentPage;

            QuoteListl1.SetDataSource(myDatasource.Items);
        }
        else
        {
            mviewLatestComments.SetActiveView(viewError);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            CurrentArchive = GetItemFromQueryString();
        }
    }
}
